package com.guigu.www.erp.yinjiaxiong.service.impl;

import com.guigu.www.erp.common.dao.SPayDetailsMapper;
import com.guigu.www.erp.common.pojo.SPayDetails;
import com.guigu.www.erp.yinjiaxiong.service.YJXsPayDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class YJXsPayDetailsServiceImpl implements YJXsPayDetailsService {
    @Autowired
    SPayDetailsMapper sPayDetailsMapper;
    @Override
    public int insertsPayDetails(SPayDetails sPayDetails) {
        //获取父序号 即上一个自增id
       // int n = sPayDetailsMapper.getMaxsPayprimaryKey();
        //由于异步 不能获到准确的父id 所以要加一
       // sPayDetails.setParentId(n+1);//设置父编号
        sPayDetails.setAmount(Integer.parseInt(sPayDetails.getPersonalValuue()));//设置数量
        sPayDetails.setAmountUnit(sPayDetails.getPersonalUnit());//设置单位
        sPayDetails.setCostPrice(sPayDetails.getRealCostPrice());
        sPayDetails.setSubtotal((sPayDetails.getAmount()*sPayDetails.getRealCostPrice()));//设置小计
        sPayDetails.setPayTag("1");//设置入库标记  1为已登记
        return sPayDetailsMapper.insertSelective(sPayDetails);
    }

    @Override
    public List<SPayDetails> BySpayIdqueryspayDetails(Integer id) {
        return sPayDetailsMapper.BySpayIdqueryspayDetails(id);
    }

    @Override
    public List<SPayDetails> ByPayIdquerySayDetails(Integer id) {
        return sPayDetailsMapper.BySpayIdqueryspayDetails(id);
    }

    @Override
    public int ByprimaryKeyupdatePaygatherTag(Integer id) {
        return sPayDetailsMapper.ByprimaryKeyupdatePaygatherTag(id);
    }

    @Override
    public List<SPayDetails> ByparentIDquery(Integer parentId) {
        return sPayDetailsMapper.ByparentIDquery(parentId);
    }

    @Override
    public int BysPayDetailsIdupdatesgatheredAmount(Integer id, Integer amount) {
        return sPayDetailsMapper.BysPayDetailsIdupdatesgatheredAmount(id,amount);
    }

    @Override
    public List<SPayDetails> ByparentIDquerypayTag2(Integer parentId) {
        return sPayDetailsMapper.ByparentIDquerypayTag2(parentId);
    }

    @Override
    public int ByspayDetailsIdupdatesgatheredAmountchecker(Integer id, Integer amount) {
        return sPayDetailsMapper.BysPayDetailsIdupdatesgatheredAmount(id,amount);
    }

    @Override
    public List<SPayDetails> BySpayIdqueryspayDetails2(Integer id) {
        return sPayDetailsMapper.BySpayIdqueryspayDetails2(id);
    }


//    @Override
//    public String ByproductIdqueryDesignCellTag(String productId) {
//        return sPayDetailsMapper.;
//    }
}
